--- import '../../styles.css' import { getSession } from '../../lib/session' import { getOAuthClient } from '../../lib/context' import { Agent } from '@atproto/api' const { handle } = Astro.params if (!handle) { return Astro.redirect('/') } const session = getSession(Astro.cookies) const oauthClient = getOAuthClient(Astro.cookies) let agent: Agent | null = null let profile: any = null let conferenceProfile: any = null let did: string | null = null let isOwnProfile = false // Get agent if authenticated if (session.did) { try { const oauthSession = await oauthClient.restore(session.did) if (oauthSession) { agent = new Agent(oauthSession) isOwnProfile = agent.assertDid === session.did } } catch (err) { console.warn('OAuth restore failed:', err) } } // Create a public agent to resolve the profile if we don't have an authenticated one const publicAgent = agent || new Agent({ service: 'https://public.api.bsky.app' }) // Resolve handle to DID and get profile try { const resolveResponse = await publicAgent.resolveHandle({ handle }) did = resolveResponse.data.did // Get Bluesky profile for basic info try { const profileResponse = await publicAgent.app.bsky.actor.getProfile({ actor: did, }) profile = profileResponse.data } catch (err) { console.warn('Failed to fetch Bluesky profile:', err) } // Get conference profile try { const response = await publicAgent.com.atproto.repo.getRecord({ repo: did, collection: 'org.atmosphereconf.profile', rkey: 'self' }) conferenceProfile = response.data.value } catch (err) { console.log('No conference profile found for this user') } } catch (err) { console.error('Failed to resolve handle:', err) return new Response('Profile not found', { status: 404 }) } // Helper function to convert blob refs to URLs function blobRefToUrl(blobRef: any, did: string): string { if (!blobRef || typeof blobRef !== 'object') return '' // Handle BlobRef object with CID if (blobRef.ref) { const cid = blobRef.ref.toString() return `https://cdn.bsky.app/img/avatar/plain/${did}/${cid}@jpeg` } return '' } const displayName = conferenceProfile?.displayName || profile?.displayName || handle const description = conferenceProfile?.description || profile?.description || '' // Handle both blob refs and direct URLs let avatar = '' if (conferenceProfile?.avatar) { avatar = blobRefToUrl(conferenceProfile.avatar, did) } else if (profile?.avatar) { avatar = profile.avatar } let banner = '' if (conferenceProfile?.banner) { banner = blobRefToUrl(conferenceProfile.banner, did) } else if (profile?.banner) { banner = profile.banner } const hasConferenceProfile = !!conferenceProfile ---
@{handle}
{did && ({did}
)}{description}
)}